package com.sh.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Collection;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultUtil implements Serializable {
    private String msg;
    private int code;
    private Object data;


    public static ResultUtil ok(String msg){
        ResultUtil util = new ResultUtil();
        util.code = 200;
        util.msg = msg;
        return util;
    }

    public static ResultUtil err(String msg){
        ResultUtil util = new ResultUtil();
        util.code = 500;
        util.msg = msg;
        return util;
    }

    public static ResultUtil data(Collection collection){
        ResultUtil util = new ResultUtil();
        util.code = 200;
        util.msg = "成功";
        util.data = collection;
        return util;
    }

    public static ResultUtil data(Object o){
        ResultUtil util = new ResultUtil();
        util.code = 200;
        util.msg = "成功";
        util.data = o;
        return util;
    }
}
